<template>
  <div id="loginPage" class="flex" :style="'background-image: url(' + bgimg + ')'">
    <div class="loLeft">
      <div class="text">
        <div><span style="font-size: 25px">1993.02.29</span> 人类历史上第一个笔网络支付业务在美国旧金山zore发生</div>
        <div style="margin-top: 40px">
          来自美国旧金山zore市的年轻人Okala抱着尝试的心态在Amazon网站进行第一笔网上支付交易，从自己的paypol账号上转出20美元，至此，人类历史上第一部笔网络支付交易诞生……
        </div>
      </div>
    </div>
    <div class="loRight flex">
    <div class="rightBox  shadow">
      <div class="imgBox">
        <img src="../../assets/img/logo.jpg" alt="">
      </div>
      <div class="inputBox flex">
        <div class="left">
         <i class="iconfont icon-user"></i>
        </div>
        <input class="right" v-model="form.username" :maxlength="10" placeholder="用户名" type="text">

      </div>
      <div class="inputBox flex">
        <div class="left">
          <i class="iconfont icon-suo"></i>
        </div>
        <input class="right" v-model="form.password" :maxlength="20"   placeholder="密码" type="password">
      </div>
      <div class="checkCode">

      </div>
      <div class="button">
        <!--<button>安全登录</button>-->
        <el-button type="warning" size="small"  :loading="login" @click="safeLogin">{{text}}</el-button>
      </div>
      <div class="forget">忘记密码？</div>
    </div>
    </div>
  </div>
</template>

<script>
  import bgimg from '../../assets/img/bg.jpg'
  import md5 from 'md5'
  export default {
    data () {
      return {
        bgimg: bgimg,
        login: false,
        form: {
          username: undefined,
          password: undefined
        },
        text: '安全登录'
      }
    },
    created () {
      let a = 1
      console.log(a)
    },
    methods: {
      safeLogin () {
        if (!this.form.username) {
          this.$message('请输入用户名')
        } else if (!this.form.password) {
          this.$message('请输入密码')
        } else {
          this.login = true
          this.text = '正在进行安全登录'
          let params = {}
          Object.assign(params, this.form)
          params.password = md5(params.password)
          this.$api.login(params).then(res => {
            if (res.code === '000000') {
              this.login = false
              this.$message.success('登录成功')
            }
          }).catch(() => {
            this.login = false
            this.text = '安全登录'
          })
        }
      }
    }
  }
</script>

<style lang="less" scoped>
  @import "../../assets/iconfont/iconfont.css";
#loginPage{
  height: 100%;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  .loLeft{
    width: 60%;
    .text{
      width: 60%;
      height: 100%;
      margin: auto;
      align-self: center;
      color: white;
      text-align: left;
      font-size: 14px;
      line-height: 30px;
    }
  }
  .loRight{
    flex: 1;
    /*justify-content: left;*/
    margin-right: 170px;
    .rightBox{
      background-color: #595459;
      /*width: 290px;*/
      width: 78%;
      height: 360px;
      border: 1px solid #edda32;

    }
    .imgBox{
      padding: 25px;
      img{
        width: 75px;
        height: 75px;
        margin: auto;
        border-radius: 50%;
      }
    }
    .inputBox{
      /*width: 195px;*/
      width: 70%;
      height: 33px;
      line-height: 34px;
      border: none;
      background-color: #f2edf2;
      margin: auto;
      margin-bottom: 20px;
      .left{
        width: 40px!important;
        /*border-right: 1px solid #ccc;*/
      }
      .right{
        flex: 1;
        border: 0;
        font-size: 13px;
        padding-left: 6px;
      }
    }
    .checkCode{
    }
    .button{
      button{
        width: 150px;
        /*height: 34px;*/
        background-color: #edda32;
        border: 0;
        border-radius: 5px;
        cursor: pointer;
        color: #000;
      }
    }
    .forget{
      font-size: 12px;
      padding: 20px;
      text-align: right;
      color: white;
      cursor: pointer;
    }
  }
}
</style>
